<%@ page language="java" pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>点球网-用户下注</title>
		<link href="css/css.css" rel="stylesheet" type="text/css" />
		<link type="text/css" href="${ctx}/css/jquery.ui.all.css" rel="stylesheet" />
		<script type="text/javascript" src="${ctx}/js/jquery.js"></script>
		<script type="text/javascript" src="${ctx}/js/jquery.ui.core.js"></script>
		<script type="text/javascript" src="${ctx}/js/jquery.ui.widget.js"></script>
		<script type="text/javascript" src="${ctx}/js/jquery.ui.accordion.js"></script>
		<script type="text/javascript">
			$(function() {
				$("#accordion").accordion();
			});
			
			//openModalDialog
			function openModalDialog(endtarget,winname,w,h)
			{ 
				
			    var	_left =(window.screen.width-w)/2 ;
				var _top = (window.screen.height-h)/2;
				
				var features =
					'dialogWidth:'+ w + 'px;'+
					'dialogHeight:' + h + 'px;'+
					'dialogLeft:'+ _left + 'px;'+
					'dialogTop:'+ _top + 'px;'+
					'directories:no; localtion:no; menubar:no; status=no; toolbar=no;scrollbars:auto;resizable=no';
			    
			    return window.showModalDialog(endtarget, winname , features);
			    //using this to receive you parmeters in your endtaget page
			    //var win=window.parent.dialogArguments;
			}
			
			function addBet(betClbId,handicapId,homeOrAwayFlag,index){
				var changeHandicapId = $("#handicapId"+index).val();
				if(betClbId == ''){
					alert("下注球队不能为空");
					return;
				}
				if(handicapId == ''&& changeHandicapId ==''){
					alert("盘口不能为空");
					return;
				}else{
					if(handicapId == ''&& changeHandicapId !=''){
						handicapId = changeHandicapId;
					}
					var num = Math.floor(Math.random()*10000);
					url="bet!turnToAdd.action?betClbId=" +betClbId+ "&handicapId="+handicapId+"&homeOrAwayFlag=" +homeOrAwayFlag+"&num="+num;
					openModalDialog(url,'',500,400);
				}
			}
			
			
			function addHandicap(matchId,index){
				var num = Math.floor(Math.random()*10000);
				url="list-handicap!getHandicap.action?matchId=" + matchId +"&num="+num;
				var handicapInfo = openModalDialog(url,'',700,500);
				if(handicapInfo != undefined && handicapInfo != null){
					var handicapInfos = handicapInfo.split(",");
					var handicapId = handicapInfos[0];
					var description = handicapInfos[1];
					var homeClbRate = handicapInfos[2];
					var awayClbRate = handicapInfos[3];
					$("#handicapId"+index).val(handicapId);
					$("#recommendMatchHandicapDescription"+index).html(description);
					$("#matchHandicapDescription"+index).html(description);
					$("#recommendMatchHomeClbRate"+index).html(homeClbRate);
					$("#matchHomeClbRate"+index).html(homeClbRate);
					$("#recommendMatchAwayClbRate"+index).html(awayClbRate);
					$("#matchAwayClbRate"+index).html(awayClbRate);
				}
			}
				
		</script>
	</head>
	<body>
		<div id="head">
			<div class="topnav">
				<ul>
				<li class="tn1"><a href="${ctx}/user-follow-clubs!showUserFollowClubs.action">主页</a></li>
				<li class="tn2"><a href="#">买彩</a></li>
				<li class="tn3"><a href="#">提彩</a></li>
				<li class="tn4"><a href="#">查账</a></li>
				<li class="tn5"><a href="#">客服</a></li>
				<li class="tn6"><a href="#">规则</a></li>
				<li class="tn7"><a href="#">注册</a></li>
				<li class="tn8"><a href="#">声明</a></li>
				<li class="tn9"><a href="#">刷新</a></li>
				<li class="right"><a href="#">齐达内，账户彩金：1000元，冻结彩金：200元。</a></li>
				</ul>
			</div>
			<div class="logo">
				<div class="cnav">
					<ul>
					<li class="cn1"><a href="${ctx}/create-match!create.action">创建比赛</a></li>
					<li class="cn2"><a href="${ctx}/match!listMatchDefault.action">查看比赛</a></li>
					<li class="cn3"><a href="${ctx}/bet!bet.action">用户下注</a></li>
					<li class="cn4"><a href="${ctx}/bet!listBet.action">查看下注</a></li>
					<li class="cn5"><a href="${ctx}/user-follow-clubs!showUserFollowClubs.action">关注球队</a></li>
					</ul>
				</div>
			</div>
			<div class="message">最新消息，本站注册用户可申请为“超级彩民”用户，超级彩民用户拥有高额返彩的机会。</div>
		</div>
		
		<div id="center">
			<div class="here">
				<span></span>您现在的位置：
				<a href="${ctx}/user-follow-clubs!showUserFollowClubs.action">点球网</a> &raquo; 
				<a href="#">用户下注</a>
			</div>
			
			<div class="cbody">
				<input type="hidden" id="handicapId" name="handicapId" value="">
				<div id="accordion">
				<h3><a href="#" style="font-size: 12px"><s:text name="N001">:</s:text></a></h3>
				<div>
				<table width="100%" border="0" cellpadding="1" cellspacing="1">
					<tr class="yhxz">
						<td style="font-size: 12px">联赛名称：</td>
						<td style="font-size: 12px">比赛时间：</td>
						<td style="font-size: 12px">盘口：</td>
						<td style="font-size: 12px">主队：</td>
						<td style="font-size: 12px">主队水率：</td>
						<td style="font-size: 12px">比分：</td>
						<td style="font-size: 12px">客队：</td>
						<td style="font-size: 12px">客队水率：</td>
						<td style="font-size: 12px">规则：</td>
						<td style="font-size: 12px">推荐下注：</td>
					</tr>
					<c:forEach items="${matchPoolList}" var="matchPool">
						<c:forEach items="${recommendMatchHandicapList}"
							var="recommendMatchHandicap" varStatus="status">
							<tr class="yhxz">
								<td style="font-size: 12px">${matchPool.dqMatch.dqLeagues.lgNameSc }</td>
								<td style="font-size: 12px">${matchPool.dqMatch.matchTime }</td>
								<td style="font-size: 12px" id="recommendMatchHandicapDescription${status.index+1 }">${recommendMatchHandicap.dqHandicapType.description}</td>
								<td style="font-size: 12px">${matchPool.dqMatch.dqClubsByHomeClbId.clbSc }
								<input type="hidden" id="handicapId${status.index+1 }" name="handicapId${status.index+1 }" value="">
								&nbsp;&nbsp;&nbsp; <a style="font-size: 12px" href="#"
									onclick="addBet('${matchPool.dqMatch.dqClubsByHomeClbId.clbId }', '${recommendMatchHandicap.hdpId }','1','${status.index+1 }')">下注</a>
								</td>
								<td style="font-size: 12px" id="recommendMatchHomeClbRate${status.index+1 }">${recommendMatchHandicap.homeClbRate}</td>
								<td style="font-size: 12px">${matchPool.dqMatch.homeScore}:${matchPool.dqMatch.awayScore
								}</td>
								<td style="font-size: 12px">${matchPool.dqMatch.dqClubsByAwayClbId.clbSc }
								<input type="hidden" id="handicapId${status.index+1 }" name="handicapId${status.index+1 }" value="">
								&nbsp;&nbsp;&nbsp; <a style="font-size: 12px" href="#"
									onclick="addBet('${matchPool.dqMatch.dqClubsByAwayClbId.clbId  }', '${recommendMatchHandicap.hdpId }','0','${status.index+1 }')">下注</a>
				
								</td>
								<td style="font-size: 12px" id="recommendMatchAwayClbRate${status.index+1 }">${recommendMatchHandicap.awayClbRate}</td>
								<td style="font-size: 12px">${matchPool.ruleId }</td>
								<td style="font-size: 12px">${matchPool.bettedInd }&nbsp;&nbsp;&nbsp;<a href="#"
									onclick="addHandicap('${matchPool.dqMatch.mthId}')">选择盘口</a></td>
							</tr>
						</c:forEach>
					</c:forEach>
				</table>
				</div>
				<c:if test="${matchDateList != null}">
					<c:forEach items="${matchDateList}" var="matchDate">
						<h3><a href="#" style="font-size: 12px">${matchDate }</a></h3>
						<div>
						<table width="100%" border="0" align="center" cellpadding="1"
							cellspacing="1">
							<tr class="yhxz">
								<td style="font-size: 12px">联赛名称：</td>
								<td style="font-size: 12px">比赛时间：</td>
								<td style="font-size: 12px">盘口：</td>
								<td style="font-size: 12px">主队：</td>
								<td style="font-size: 12px">主队水率：</td>
								<td style="font-size: 12px">比分：</td>
								<td style="font-size: 12px">客队：</td>
								<td style="font-size: 12px">客队水率：</td>
								<td style="font-size: 12px">选择盘口：</td>
							</tr>
							<c:forEach items="${matchList}" var="match" varStatus="status">
								<c:if test="${matchDate == match.matchDate}">
									<tr>
										<td style="font-size: 12px">${match.dqLeagues.lgNameSc }</td>
										<td style="font-size: 12px">${match.matchTime }</td>
				
										<c:if test="${handicapList != null}">
											<c:forEach items="${handicapList}" var="handicap">
												<c:if test="${handicap.dqMatch.mthId == match.mthId}">
													<td style="font-size: 12px"  id="matchHandicapDescription${status.index+1 }">${handicap.dqHandicapType.description}</td>
												</c:if>
											</c:forEach>
										</c:if>
										<c:if test="${handicapList == null}">
											<td id="matchHandicapDescription${status.index+1 }"></td>
										</c:if>
				
										<td style="font-size: 12px">${match.dqClubsByHomeClbId.clbSc } 
											<input type="hidden" id="handicapId${status.index+1 }" name="handicapId${status.index+1 }" value="">
											&nbsp;&nbsp;&nbsp; 
											<a href="#" onclick="addBet('${match.dqClubsByHomeClbId.clbId }','${handicap.hdpId }','1','${status.index+1 }')">下注</a>
										</td>
				
										<c:if test="${handicapList != null}">
											<c:forEach items="${handicapList}" var="handicap">
												<c:if test="${handicap.dqMatch.mthId == match.mthId}">
													<td style="font-size: 12px" id="matchHomeClbRate${status.index+1 }">${handicap.homeClbRate
													}</td>
												</c:if>
											</c:forEach>
										</c:if>
										<c:if test="${handicapList == null}">
											<td style="font-size: 12px" id="matchHomeClbRate${status.index+1 }"></td>
										</c:if>
				
										<td style="font-size: 12px">${homeScore} : ${awayScore }</td>
				
										<td style="font-size: 12px">${match.dqClubsByAwayClbId.clbSc } 
											<input type="hidden" id="handicapId${status.index+1 }" name="handicapId${status.index+1 }" value="">
								
											&nbsp;&nbsp;&nbsp; 
											<a style="font-size: 12px" href="#" onclick="addBet('${match.dqClubsByAwayClbId.clbId }','${handicap.hdpId }','0','${status.index+1 }')">下注</a>
										</td>
				
										<c:if test="${handicapList != null}">
											<c:forEach items="${handicapList}" var="handicap">
												<c:if test="${handicap.dqMatch.mthId == match.mthId}">
													<td style="font-size: 12px" id="matchAwayClbRate${status.index+1 }">${handicap.awayClbRate
													}</td>
												</c:if>
											</c:forEach>
										</c:if>
										<c:if test="${handicapList == null}">
				
											<td style="font-size: 12px" id="matchAwayClbRate${status.index+1 }"></td>
										</c:if>
				
										<td><a style="font-size: 12px" href="#"
											onclick="addHandicap('${match.mthId}','${status.index+1 }')">选择盘口</a></td>
									</tr>
								</c:if>
							</c:forEach>
						</table>
						</div>
					</c:forEach>
				</c:if>
				</div>
			</div>
		</div>
		
		
		<div id="footer">
			<div class="fnav">
				<a href="#">关于我们</a> | 
				<a href="#">关于我们</a> | 
				<a href="#">关于我们</a> | 
				<a href="#">关于我们</a> | 
				<a href="#">关于我们</a> | 
				<a href="#">关于我们</a> | 
				<a href="#">关于我们</a> | 
				<a href="#">关于我们</a>
			</div>
			<div class="bq">Copyright ? 2010 点球网 保留所有版权。</div>
		</div>
	</body>
</html>
